package com.travel.rabbit.service.impl;

import com.travel.rabbit.entity.AdminRabbit;
import com.travel.rabbit.dao.AdminRabbitDao;
import com.travel.rabbit.service.AdminRabbitService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AdminRabbit)表服务实现类
 *
 * @author makejava
 * @since 2022-01-05 10:54:13
 */
@Service("adminRabbitService")
public class AdminRabbitServiceImpl implements AdminRabbitService {
    @Resource
    private AdminRabbitDao adminRabbitDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AdminRabbit queryById(Integer id) {
        return this.adminRabbitDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<AdminRabbit> queryAllByLimit(int offset, int limit) {
        return this.adminRabbitDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param adminRabbit 实例对象
     * @return 实例对象
     */
    @Override
    public AdminRabbit insert(AdminRabbit adminRabbit) {
        this.adminRabbitDao.insert(adminRabbit);
        return adminRabbit;
    }

    /**
     * 修改数据
     *
     * @param adminRabbit 实例对象
     * @return 实例对象
     */
    @Override
    public AdminRabbit update(AdminRabbit adminRabbit) {
        this.adminRabbitDao.update(adminRabbit);
        return this.queryById(adminRabbit.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.adminRabbitDao.deleteById(id) > 0;
    }
}